package h0811;

import java.util.*;
/**
  * @description 符号计算
  * @author 不知名帅哥
  * @date 2024/8/12 11:42
  * @version 1.0
*/
public class ExpressionEvaluator {
    
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String expression = scanner.nextLine();
        scanner.close();
        
        try {
            Fraction result = evaluateExpression(expression);
            System.out.println(result);
        } catch (ArithmeticException e) {
            System.out.println("ERROR");
        }
    }
    
    private static Fraction evaluateExpression(String expression) {
        List<String> postfix = infixToPostfix(expression);
        return evaluatePostfix(postfix);
    }
    
    private static List<String> infixToPostfix(String expression) {
        List<String> output = new ArrayList<>();
        Stack<String> stack = new Stack<>();
        StringTokenizer tokenizer = new StringTokenizer(expression, " +-*/()", true);
        
        while (tokenizer.hasMoreTokens()) {
            String token = tokenizer.nextToken().trim();
            if (token.isEmpty()) continue;
            
            if (isNumber(token)) {
                output.add(token);
            } else if (token.equals("(")) {
                stack.push(token);
            } else if (token.equals(")")) {
                while (!stack.isEmpty() && !stack.peek().equals("(")) {
                    output.add(stack.pop());
                }
                stack.pop();
            } else if (isOperator(token)) {
                while (!stack.isEmpty() && precedence(stack.peek()) >= precedence(token)) {
                    output.add(stack.pop());
                }
                stack.push(token);
            }
        }
        
        while (!stack.isEmpty()) {
            output.add(stack.pop());
        }
        
        return output;
    }
    
    private static Fraction evaluatePostfix(List<String> postfix) {
        Stack<Fraction> stack = new Stack<>();
        
        for (String token : postfix) {
            if (isNumber(token)) {
                stack.push(new Fraction(Integer.parseInt(token), 1));
            } else if (isOperator(token)) {
                Fraction b = stack.pop();
                Fraction a = stack.pop();
                
                switch (token) {
                    case "+":
                        stack.push(a.add(b));
                        break;
                    case "-":
                        stack.push(a.subtract(b));
                        break;
                    case "*":
                        stack.push(a.multiply(b));
                        break;
                    case "/":
                        stack.push(a.divide(b));
                        break;
                }
            }
        }
        
        return stack.pop();
    }
    
    private static boolean isNumber(String token) {
        try {
            Integer.parseInt(token);
            return true;
        } catch (NumberFormatException e) {
            return false;
        }
    }
    
    private static boolean isOperator(String token) {
        return "+-*/".contains(token);
    }
    
    private static int precedence(String operator) {
        switch (operator) {
            case "+":
            case "-":
                return 1;
            case "*":
            case "/":
                return 2;
        }
        return -1;
    }
    
    static class Fraction {
        int numerator;
        int denominator;
        
        Fraction(int numerator, int denominator) {
            if (denominator == 0) {
                throw new ArithmeticException("Division by zero");
            }
            this.numerator = numerator;
            this.denominator = denominator;
            simplify();
        }
        
        Fraction add(Fraction other) {
            int num = this.numerator * other.denominator + other.numerator * this.denominator;
            int den = this.denominator * other.denominator;
            return new Fraction(num, den);
        }
        
        Fraction subtract(Fraction other) {
            int num = this.numerator * other.denominator - other.numerator * this.denominator;
            int den = this.denominator * other.denominator;
            return new Fraction(num, den);
        }
        
        Fraction multiply(Fraction other) {
            int num = this.numerator * other.numerator;
            int den = this.denominator * other.denominator;
            return new Fraction(num, den);
        }
        
        Fraction divide(Fraction other) {
            int num = this.numerator * other.denominator;
            int den = this.denominator * other.numerator;
            return new Fraction(num, den);
        }
        
        private void simplify() {
            int gcd = gcd(Math.abs(numerator), Math.abs(denominator));
            numerator /= gcd;
            denominator /= gcd;
            if (denominator < 0) {
                numerator = -numerator;
                denominator = -denominator;
            }
        }
        
        private int gcd(int a, int b) {
            while (b != 0) {
                int temp = b;
                b = a % b;
                a = temp;
            }
            return a;
        }
        
        @Override
        public String toString() {
            if (denominator == 1) {
                return String.valueOf(numerator);
            } else {
                return numerator + "/" + denominator;
            }
        }
    }
}
